export const extractNumberAndUnit = (value: string) => {
  const match = value.match(/^(\d+(\.\d+)?)(\w+)$/);
  if (match) {
    const number = parseFloat(match[1]); // 数字部分
    const unit = match[3];               // 单位部分
    return { number, unit };
  }
  return null
}


//获取参数
export function getUrlKey(name: string) {
  try {
    let href = window.location.href;
    var query = decodeURIComponent(href.split('?')[1]);
    var vars = query.split("&");
    for (var i = 0;i < vars.length;i++) {
      var pair = vars[i].split("=");
      if (pair[0] == name) {
        return pair[1];
      }
    }
  } catch (e) {
    return ''
  }
}

//获取参数
export function removeUrlKey(name: string) {
  try {
    let href = window.location.href;
    var query = decodeURIComponent(href.split('?')[1]);
    var vars = query.split("&");
    for (var i = 0;i < vars.length;i++) {
      var pair = vars[i].split("=");
      if (pair[0] == name) {
        return pair[1];
      }
    }
  } catch (e) {
    return ''
  }
}